/* GUI CONVERTED from repm.p (converter v1.76) Wed May  8 14:09:17 2002 */
/* repm.p - REPETITIVE MODULE PARAMETER MAINTENANCE                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5.2.5 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3      LAST MODIFIED: 09/08/92   BY: emb *G071* */
/* REVISION: 7.3      LAST MODIFIED: 10/08/92   BY: emb *G148* */
/* REVISION: 7.3      LAST MODIFIED: 01/11/93   BY: emb *G689* */
/* REVISION: 7.3      LAST MODIFIED: 09/21/94   BY: pxd *GM79* */
/* REVISION: 7.3      LAST MODIFIED: 11/30/94   BY: srk *GO58* */
/* REVISION: 7.3      LAST MODIFIED: 05/18/95   BY: str *G0N2* */
/* REVISION: 7.3      LAST MODIFIED: 05/14/96   BY: *G1VF* Julie Milligan     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 07/30/98   BY: *J2TH* Sandesh Mahagaokar */
/* REVISION: 9.1      LAST MODIFIED: 06/28/00   BY: *N0DM* Mudit Mehta        */
/* REVISION: 9.1      LAST MODIFIED: 08/02/00   BY: *N0HG* Jean Miller        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 09/26/00   BY: *N0WD* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.5.2.5 $   BY: Jean Miller        DATE: 05/07/02  ECO: *P066*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdtitle.i "2+ "}
{cxcustom.i "REPM.P"}

define new shared variable module like mfc_module.

define variable i as integer.
define variable ii as integer.
define variable ok_days as character extent 9.
define variable ok_string as character.

assign
   ok_days[1]  = getTermLabel("NONE",12)
   ok_days[2]  = getTermLabel("SUNDAY",12)
   ok_days[3]  = getTermLabel("MONDAY",12)
   ok_days[4]  = getTermLabel("TUESDAY",12)
   ok_days[5]  = getTermLabel("WEDNESDAY",12)
   ok_days[6]  = getTermLabel("THURSDAY",12)
   ok_days[7]  = getTermLabel("FRIDAY",12)
   ok_days[8]  = getTermLabel("SATURDAY",12)
   ok_days[9]  = getTermLabel("TODAY",12).

{mfpmform.i}

{&REPM-P-TAG1}
find first rpc_ctrl exclusive-lock no-error.
if not available rpc_ctrl then create rpc_ctrl.

rpcwkstart = ok_days[rpc_wk_start modulo 9  + 1].

do i = 1 to 9:
   ok_string = ok_string + "," + ok_days[i].
end.

repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* DISPLAY */
   ststatus = stline[3].
   status input ststatus.

   view frame repm-a.

   display
      rpc_nbr
      rpc_nbr_pre
      rpc_sch_fwd
      rpc_sch_bck
      rpcwkstart
   with frame repm-a.

   do on error undo, retry with frame repm-a:
/*GUI*/ if global-beam-me-up then undo, leave.

      set
         rpc_nbr
         rpc_nbr_pre
         rpc_sch_fwd
         rpc_sch_bck
         rpcwkstart  validate
            (can-do(ok_days[1] + "," + ok_days[2] + "," + ok_days[3]
            + "," + ok_days[4] + "," + ok_days[5] + "," + ok_days[6]
            + "," + ok_days[7] + "," + ok_days[8] + "," + ok_days[9] ,
            input rpcwkstart),
            getTermLabel("VALID_INPUT",15) + ": "
            + ok_days[1] + "," + ok_days[2] + "," + ok_days[3] + ","
            + ok_days[4] + "," + ok_days[5] + "," + ok_days[6] + ","
            + ok_days[7] + "," + ok_days[8] + "," + ok_days[9] )
      with frame repm-a
      editing:

         if frame-field = "rpcwkstart" then do:
            ststatus = stline[1].
            status input ststatus.
         end.
         else do:
            ststatus = stline[2].
            status input ststatus.
         end.

         readkey.

         if frame-field = "rpcwkstart" then do:

            if lastkey = keycode("F10")
            or keyfunction(lastkey) = "DELETE-LINE"
            or keyfunction(lastkey) = "PAGE-DOWN"
            or keyfunction(lastkey) = "CURSOR-DOWN"
            or lastkey = 32
            then do:
               rpc_wk_start = (rpc_wk_start + 1) modulo 9.
               display
                  ok_days[rpc_wk_start + 1] @ rpcwkstart.
               next.
            end.

            else
            if lastkey = keycode("F9")
            or keyfunction(lastkey) = "NEW-LINE"
            or keyfunction(lastkey) = "PAGE-UP"
            or keyfunction(lastkey) = "CURSOR-UP"
            then do:
               rpc_wk_start = (rpc_wk_start - 1) modulo 9.
               display ok_days[rpc_wk_start + 1] @ rpcwkstart.
               next.
            end.

            else do:
               apply lastkey.

               if can-do(ok_days[1] + "," + ok_days[2] + "," + ok_days[3]
                  + "," + ok_days[4] + "," + ok_days[5] + "," + ok_days[6]
                  + "," + ok_days[7] + "," + ok_days[8] + "," + ok_days[9],
                  input rpcwkstart)
               then do:
                  rpc_wk_start = lookup(input rpcwkstart,
                     ok_days[1] + "," + ok_days[2] + "," + ok_days[3] + ","
                     + ok_days[4] + "," + ok_days[5] + "," + ok_days[6] + ","
                     + ok_days[7] + "," + ok_days[8] + "," + ok_days[9]) - 1.
               end.

               else do:

                  do i = length(input rpcwkstart) to 1 by -1:

                     if index(ok_string,
                        "," + substring(input rpcwkstart,1,i)) <> 0
                     then do:
                        rpcwkstart = substring(ok_string,
                           index(ok_string,substring(input rpcwkstart,1,i))).
                        rpcwkstart = substring(rpcwkstart + ",",1,
                           index(rpcwkstart + "," , ",") - 1).
                        rpc_wk_start =
                           (lookup(rpcwkstart,ok_string) - 1) modulo 9.
                        display rpcwkstart.
                        leave.
                     end.

                  end.

                  if i <> 0 then next.
               end.

            end.

         end.

         else do:
            apply lastkey.
         end.

      end.

      if length(rpc_nbr_pre + string(rpc_nbr)) > 10 then
      do with frame repm-a:
         /* Prefix and number combined cannot exceed # characters */
         {pxmsg.i &MSGNUM=312 &ERRORLEVEL=3
                  &MSGARG1=getTermLabel(""TEN"",20)}
         undo, retry.
      end.

   end.
/*GUI*/ if global-beam-me-up then undo, leave.


end.
/*GUI*/ if global-beam-me-up then undo, leave.


{&REPM-P-TAG2}
status input.
